# from curl_cffi import requests
import asyncio, aiohttp
import requests
import threading
from util.headers import get_header

header = get_header("https://quote.eastmoney.com/center/gridlist.html")
header.update(
    {
        "cookie": "fullscreengg=1; fullscreengg2=1; qgqp_b_id=db7733eea6915ce9c649b4e830a49db3; st_nvi=4pi3daSaztKQgaVsX7P7-158f; st_si=05375851842477; st_asi=delete; nid=00ed6e0a1bdeac198d1c380ec1d22ebb; nid_create_time=1762236218459; gvi=-af7JRJK5U9_5q_elTl68bab0; gvi_create_time=1762236218459; st_pvi=03663629500679; st_sp=2025-11-04%2014%3A03%3A37; st_inirUrl=https%3A%2F%2Fquote.eastmoney.com%2Fcenter%2Fgridlist.html; st_sn=4; st_psi=20251104155539926-113300300812-7605758462"
    }
)
urls = [
    f"https://push2.eastmoney.com/api/qt/clist/get?np=1&fltt=1&invt=2&fs=m%3A0%2Bt%3A6%2Bf%3A!2%2Cm%3A0%2Bt%3A80%2Bf%3A!2%2Cm%3A1%2Bt%3A2%2Bf%3A!2%2Cm%3A1%2Bt%3A23%2Bf%3A!2%2Cm%3A0%2Bt%3A81%2Bs%3A262144%2Bf%3A!2&fields=f12%2Cf13%2Cf14%2Cf1%2Cf2%2Cf4%2Cf3%2Cf152%2Cf5%2Cf6%2Cf7%2Cf15%2Cf18%2Cf16%2Cf17%2Cf10%2Cf8%2Cf9%2Cf23&fid=f3&pn={i}&pz=20&po=1&dect=1&ut=fa5fd1943c7b386f172d6893dbfba10b&wbp2u=%7C0%7C0%7C0%7Cweb&_=1762236231801"
    for i in range(1, 274)
]
# rl = "https://push2.eastmoney.com/api/qt/clist/get?np=1&fltt=1&invt=2&cb=jQuery37104912624207644263_1762237377008&fs=m%3A0%2Bt%3A6%2Bf%3A!2%2Cm%3A0%2Bt%3A80%2Bf%3A!2%2Cm%3A1%2Bt%3A2%2Bf%3A!2%2Cm%3A1%2Bt%3A23%2Bf%3A!2%2Cm%3A0%2Bt%3A81%2Bs%3A262144%2Bf%3A!2&fields=f12%2Cf13%2Cf14%2Cf1%2Cf2%2Cf4%2Cf3%2Cf152%2Cf5%2Cf6%2Cf7%2Cf15%2Cf18%2Cf16%2Cf17%2Cf10%2Cf8%2Cf9%2Cf23&fid=f3&pn=1&pz=20&po=1&dect=1&ut=fa5fd1943c7b386f172d6893dbfba10b&wbp2u=%7C0%7C0%7C0%7Cweb&_=1762237377012"
# # for url in urls:
# res = requests.get(
#     rl,
#     headers=get_header(
#         "https://quote.eastmoney.com/center/gridlist.html",
#     ),
# )
# print(res.text)


async def fetch(session, url):
    async with session.get(url, headers=header) as f:
        return await f.text()


async def main():
    async with aiohttp.ClientSession() as session:
        res = await asyncio.gather(*[fetch(session, url) for url in urls])
        for ress in res:
            print(ress)
            break


asyncio.run(main())
